import http from "./http";

// 用户登录
export const userLogin = async (userName: string, userPwd: string) => {
    const data = await http.post('http://localhost:3000/api/user/user-login', {
        userName,
        userPwd,
    })
    return data
}
// 用户注册
export const userRegister = async (userName: string, userPwd: string, email: string) => {
    const data = await http.post('http://localhost:3000/api/user/user-register', {
        userName,
        userPwd,
        email,
    })
    return data
}
// 用户修改密码
export const userChangePassword = async (oldpass: string, newpass: string, username: string | null) => {
    const data = await http.post('http://localhost:3000/api/user/user-chang-password', {
        oldpass, newpass, username
    })
    return data
}
// 用户忘记密码，重置密码
export const userResetPassword = async (username: string | null) => {
    const data = await http.post('http://localhost:3000/api/user/user-reset-password', {
        username
    })
    return data
}

// 获取全部用户列表(用户名)
export const getAllUser = async () => {
    const { data } = await http.get('http://localhost:3000/api/getAllUser', {})
    return data
}
// 获取全部用户列表
export const getAllUserList = async () => {
    const { data } = await http.get('http://localhost:3000/api/getAllUserList', {})
    return data
}

//新增用户
export const addUser = async (userInfo: any) => {
    const data = await http.post('http://localhost:3000/api/addUser', { userInfo })
    return data
}
//更新用户
export const updateUser = async (userInfo: any) => {
    const data = await http.post('http://localhost:3000/api/updateUser', { userInfo })
    return data
}
// 删除用户
export const deleteUser = async (id: number) => {
    const data = await http.post('http://localhost:3000/api/deleteUser', { id })
    return data
}
//新增房间
export const addRoom = async (roomInfo: any) => {
    const data = await http.post('http://localhost:3000/api/addRoom', { roomInfo })
    return data
}
// 获取全部房间列表
export const getAllRoomList = async () => {
    const { data } = await http.get('http://localhost:3000/api/getAllRoomList', {})
    return data
}
//更新房间
export const updateRoom = async (roomInfo: any) => {
    const data = await http.post('http://localhost:3000/api/updateRoom', { roomInfo })
    return data
}
// 删除房间
export const deleteRoom = async (id: number) => {
    const data = await http.post('http://localhost:3000/api/deleteRoom', { id })
    return data
}
// 分组查询全部房间
export const getGroupRoomList = async () => {
    const { data } = await http.get('http://localhost:3000/api/getGroupRoomList', {})
    return data
}
// 录入信息
export const roomCostInfo = async (roomForm: any) => {
    const { data } = await http.post('http://localhost:3000/api/roomCostInfo', { roomForm })
    return data
}
// 数据统计
export const dataStatistics = async () => {
    const { data } = await http.get('http://localhost:3000/api/dataStatistics', {})
    return data
}
// 删除房间
export const deleteCost = async (id: number) => {
    const data = await http.post('http://localhost:3000/api/deleteCost', { id })
    return data
}
// 查询物业的基本信息
export const getPropertyInfo = async () => {
    const { data } = await http.get('http://localhost:3000/api/getPropertyInfo', {})
    return data
}
// 管理员登录
export const getLogin = async (loginInfo: any) => {
    const { data } = await http.post('http://localhost:3000/api/userLogin', { loginInfo })
    return data
}
// 数据分析统计用户和房屋总数
export const getAllUserRoomNumber = async () => {
    const { data } = await http.get('http://localhost:3000/api/getAllUserRoomNumber', {})
    return data
}
// 数据分析统计cost表
export const getCostDataAnalysis = async (year:number,month:number) => {
    const { data } = await http.get('http://localhost:3000/api/costDataAnalysis', { year,month })
    return data
}
//用户打印数据
export const userExportExcle = async (year:number,month:number) => {
    const {data} = await http.get('http://localhost:3000/api/exportExcle',{year,month})
    return data
}